import operate from '@dfeidao/atom-nodejs/db/operate';
import { IncomingHttpHeaders } from 'http';
// tslint:disable-next-line: ordered-imports
import { productid,systemid } from '../../atom/config';

interface Message {
	filter: {
		productid: string,
		topic_type: string,
		topic: string,
		right_answer: string,
		question_no: string
	};
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}



export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders) {
	const { exec, update } = operate(action_id, session_id, systemid);
	// 插入数据
	update('question_bank',{productid,question_no:message.filter.question_no}, {
		productid:message.filter.productid,
		topic_type:message.filter.topic_type,
		topic:message.filter.topic,
		right_answer:message.filter.right_answer

	});
	const res = await exec();
	return res;
}
